# Sentinel - IRC Statistical and Operator Services
# Makefile - source directory Makefile
#
# Copyright W. Campbell and others.  See README for more details
# Some code Copyright: Jonathan George, Kai Seidler, ircd-hybrid Team,
#                      IRCnet IRCD developers.
#
# $Id: Makefile 7 2010-02-01 19:17:42Z dubkat $

MAKE = make 'CC=${CC}' 'CFLAGS=${CFLAGS}' 'LDFLAGS=${LDFLAGS}' \
            'BIN=${BIN}' 'MKPASSWD=${MKPASSWD}' 'TEMPLATE=${TEMPLATE}' \
            'RM=${RM}' 'AWK=${AWK}' 'MV=${MV}'

SRCS =	adminserv.c \
	bconf.c \
	capab.c \
	challenge.c \
	channels.c \
	connection.c \
	datadump.c \
	dcc.c \
	evh.c \
	flags.c \
	hidden.c \
	hosthash.c \
	htmlsup.c \
	init.c \
	ircd.c \
	ircdsup.c \
	jupe.c \
	jupeserv.c \
	listserv.c \
	main.c \
	monserv.c \
	myusers.c \
	operlist.c \
	pubstats.c \
	send.c \
	servers.c \
	sock.c \
	split-data.c \
	split-util.c \
	splitserv.c \
	stats.c \
	statserv.c \
	tld.c \
	users.c \
	util.c

OBJS = ${SRCS:.c=.o}

IOBJS = info.o

ISRCS = info.c

HOBJS = html.o

HSRCS = html.c

LIBDIR = libsentinel

.c.o:
	$(CC) $(CFLAGS) $(MFLAGS) -c $<

default:
	@echo Run make from the root

all: sentinel

build: all

clean:
	@for i in $(LIBDIR); do \
		echo Cleaning libsentinel.a...; \
		cd $$i; \
		make clean; \
		cd ..; \
	done
	$(RM) -f *.o core sentinel.core info.c html.c geninfo.sh.patch

sentinel: src/libsentinel.a $(OBJS) $(IOBJS) $(HOBJS)
	$(CC) $(OBJS) $(IOBJS) $(HOBJS) -Llibsentinel -lsentinel $(LDFLAGS) $(LIBS) -o ../bin/$(BIN)
	$(MV) info.c info.c.last

src/libsentinel.a:
	@for i in $(LIBDIR); do \
		echo Building libsentinel.a...; \
		cd $$i; \
		make build; \
		cd ..; \
	done

cleandir: clean

distclean: clean

lint:	
	lint -aacgprxhH -I../include $(SRCS) >../lint.out

lclint:
	lclint -I../include $(SRCS) >../lint.out

depend:
	$(CC) -MM $(CFLAGS) $(SRCS) > .depend

info.c:	geninfo.sh ../include/patchlevel.h ../include/serno.h
	@/bin/sh geninfo.sh

html.c: genhtml.sh genhtml.awk ../html/$(TEMPLATE) ../include/patchlevel.h \
	../include/serno.h ../include/proto.h ../include/struct.h \
	../include/config.h ../include/stats.h ../src/libsentinel/dlink.h \
	../include/lang.h
	@echo Generating html.c...
	@/bin/sh genhtml.sh <../html/$(TEMPLATE) >html.c

html.o:	html.c
	$(CC) -g -O2 -I../include -I../src/libsentinel -c html.c

info.o: info.c
	$(CC) -g -O2 -I../include -I../src/libsentinel -c info.c

## Rules are done, now dependencies

# Catch any changes in compilation options at the top of this file
$(OBJS): ../Makefile Makefile

include .depend
